/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package BackingBeans;

import BeanManager.GetMembreRecherche;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.model.SelectItem;
import packageEntities.Membre;

/**
 *
 * @author gngueken
 */
@ManagedBean
@RequestScoped
public class RecherchePersonne {
     private String sexe;
    private String ville;
    private int age;
    List<Membre> laListeMbre;
    private boolean isData;

    /**
     * Creates a new instance of RecherchePersonne
     */
    public RecherchePersonne() {
    }
    
    
     private int ageMax, ageMin;
    ArrayList<String> listDeSex;
    ArrayList<String> listDeTeint;
    ArrayList<String> listDeVille;
   
    
    private ArrayList<SelectItem> listSex, listTeint, listVille;
    
    
    @PostConstruct
    public void initData(){
        listSex = new ArrayList<>();
        listDeSex = new ArrayList<>();
        listDeSex.add("Femme");
        listDeSex.add("Homme");
        listDeSex.add("Couple");
        for (int i = 0; i <= listDeSex.size()-1; i++) {
            SelectItem valueSex = new SelectItem();
            valueSex.setValue(listDeSex.get(i));
            listSex.add(valueSex);
        }
        
        listDeTeint = new ArrayList<>();
        listDeTeint.add("Noir");
        listDeTeint.add("Jaune");
        listDeTeint.add("Brun");
        listDeTeint.add("Blanc");
        listTeint = new ArrayList<>();
         for (int i = 0; i <= listDeTeint.size()-1; i++) {
            SelectItem valueSex = new SelectItem();
            valueSex.setValue(listDeTeint.get(i));
            listTeint.add(valueSex);
        }
         
         
        listDeVille = new ArrayList<>();
        listDeVille.add("Montreal");
        listDeVille.add("Quebec");
        listDeVille.add("Gatinaux");
        listDeVille.add("Otawa");
        listVille = new ArrayList<>();
        for (int i = 0; i <= listDeVille.size()-1; i++) {
            SelectItem valueSex = new SelectItem();
            valueSex.setValue(listDeVille.get(i));
            listVille.add(valueSex);
        }
       
        
    }

    public int getAgeMax() {
        return ageMax;
    }

    public void setAgeMax(int ageMax) {
        this.ageMax = ageMax;
    }

    public int getAgeMin() {
        return ageMin;
    }

    public void setAgeMin(int ageMin) {
        this.ageMin = ageMin;
    }

    public ArrayList<SelectItem> getListSex() {
        return listSex;
    }

    public void setListSex(ArrayList<SelectItem> listSex) {
        this.listSex = listSex;
    }

    public ArrayList<SelectItem> getListTeint() {
        return listTeint;
    }

    public void setListTeint(ArrayList<SelectItem> listTeint) {
        this.listTeint = listTeint;
    }

    public ArrayList<SelectItem> getListVille() {
        return listVille;
    }

    public void setListVille(ArrayList<SelectItem> listVille) {
        this.listVille = listVille;
    }

    public List<Membre> getLaListeMbre() {
        return laListeMbre;
    }

    public void setLaListeMbre(List<Membre> laListeMbre) {
        this.laListeMbre = laListeMbre;
    }

    public boolean isIsData() {
        return isData;
    }

    public void setIsData(boolean isData) {
        this.isData = isData;
    }

    public String getSexe() {
        return sexe;
    }

    public void setSexe(String sexe) {
        this.sexe = sexe;
    }

    public String getVille() {
        return ville;
    }

    public void setVille(String ville) {
        this.ville = ville;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
   
    //methode de la recherche

     public String rechercher(){
       // String recherche = null;
        HashMap listParam = new HashMap();
        if(ville != null)
        listParam.put("ville", "%"+ville+"%");
        listParam.put("age", age);
        listParam.put("sexe",sexe);

        laListeMbre = GetMembreRecherche.AfficherLesMembres(listParam);

        return null;
        
//        if(age!= 0){
//            listeface.put("age", age);
//        }
//        
//         if(ville!= null){
//            listeface.put("ville",ville);
//        }
        
    }
    
   
    
}
